package de.tum.in.eist.im.client.GUIwidgets;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;

import de.tum.in.eist.im.client.EIST_IM;

public class UserPrompt extends UserDialog {
	EIST_IM returnTo;

	public UserPrompt(String text, final EIST_IM returnTo) {
		super(text);
		this.returnTo = returnTo;

		inputBox.setText("groupname");

		cancelButton = new Button("Cancel");
		
		panel.insert(inputBox, 0);
		panel.add(cancelButton);
		
		inputBox.selectAll();
		
		addHandlerToWidgets();
	}
	
	public void addHandlerToWidgets() {
		OKButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				if (!inputBox.getText().equals("")) {
					inviteDialog.hide();
					returnTo.addGroup(inputBox.getText());
				}
			}
		});
		cancelButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				inviteDialog.hide();
			}
		});
	}
}
